# -*- coding: utf-8 -*-

#(c)Jonathan & Gregoire (read __doc__ for more information)
#Copyright (C)%(author)s (%(date)s)
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

## @package engine
# This package is used for run the game.
# @note The game use MVC pattern design and is compartmentalized in 3 subpackage : controller,pattern and view

__author__      = \
"""
Jonathan MERCIER <bioinfornatics at gmail.com >
Gregoire NAUDIN  <greg.naudin at gmail.com    >
"""
__version__     = "$Revision: 0.1 $"
__date__        = "$Date: 2009/23/09$"
__copyright__   = "Copyright (c) 2009 Jonathan MERCIER and Gregoire NAUDIN"
__license__     = "GPL v3 or under"
__name__        = "Singleton.py"
__description__ = \
"""
Singleton class is used for each child can be instaciated several times, but all same objects have the same state.
"""

## Documentation for Singleton class
# @brief This class is the Singleton definition object<br>
# This class is used for each child can be instanciated several times, but all same objects have the same state.<br>
# If you create a class B where the super class is Singleton<br>
# you can create an object b and an another object a from the class B.<br>
# They are 2 instance but a and b have always the same state.<br>
# Example:<br>
# > class B(Singleton):<br>
# ...    pass<br>
# ...<br>
# > a = B()<br>
# > b = B()<br>
# > a.myAttribute = 1<br>
# > b.myAttribute<br>
# 1<br>
# > b.myAttribute = 2<br>
# > a.myAttribute<br>
# 2<br>
# > a is b<br>
# False<br>
# @return: instance
class Singleton(object):
    _shared_state = {}
    def __new__(cls,*args,**kw):
        instance            = super(Singleton, cls).__new__(cls, *args, **kw)
        instance.__dict__   = cls._shared_state
        return instance